package year2021.month08910;

import com.alibaba.fastjson.JSON;
import org.apache.storm.shade.org.apache.commons.lang.StringUtils;

import java.util.*;

public class StringTest {
    public static void main(String[] args){
        String str = "123" + "666";
        System.out.println(str);
        str = str.substring("123".length());
        System.out.println(str);

        str = JSON.toJSONString(str);
        System.out.println(str);

        HashMap<String, Object> para = new HashMap<>();
        para.put("k1", "111");
        para.put("k2", "222");

        List<HashMap<String, Object>> goods = new ArrayList<>();
        HashMap<String, Object> row = new HashMap<>();
        row.put("i3", "333");
        row.put("i5", "555");
        goods.add(row);

        para.put("goods", goods);

        String pr = JSON.toJSONString(para);
        System.out.println(pr);


        System.out.println("0123456".substring(0,5));
        Random ran = new Random();
        for (int i=0; i<100; i++){
            System.out.print(ran.nextInt(10) + "\t");
        }


        System.out.println(StringUtils.substringBefore("dskeabcee", "e"));
//        结果是：dsk

        System.out.println(StringUtils.substringBeforeLast("dskeabcee", "e"));//一直找到最后一个指定的字符串
//        结果是：dskeabce

        System.out.println(StringUtils.substringAfter("dskeabcee666", "e"));
//        结果是：abcee666

        System.out.println(StringUtils.substringAfterLast("dskeabcee666", "e"));
//        结果是：666
    }
}
